home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 November / Macworld (1999-11).dmg / Updaters / WhiteCap 3.0.4 / WhiteCap Source.sit / WhiteCap Source / Common / io / ConfigFile.cpp < prev    next >
C/C++ Source or Header  |  1999-07-13  |  842b  |  44 lines

  1. #include "ConfigFile.h"
  2.  
  3. #include "CEgFileSpec.h"
  4. #include "CEgIFile.h"
  5. #include "ArgList.h"
  6.  
  7.  
  8. bool ConfigFile::Load( const CEgFileSpec* inSpec, ArgList& outArgs ) {
  9.     UtilStr str, configText, num;
  10.     CEgIFile file;
  11.     int i, end;
  12.     
  13.     file.open( inSpec );
  14.     
  15.     if ( file.noErr() ) { 
  16.     
  17.         // Read the config and chuck any comments
  18.         while ( file.noErr() ) {
  19.             file.Readln( str );
  20.             i = str.contains( "//" );
  21.             if ( i > 0 )
  22.                 str.Keep( i - 1 );
  23.             configText.Append( str );
  24.         } 
  25.         file.throwErr( cNoErr );
  26.         
  27.         // Remove block comments
  28.         do {
  29.             i = configText.contains( "/*" );
  30.             if ( i > 0 ) {
  31.                 end = configText.contains( "*/" );
  32.                 if ( end > 0 )
  33.                     configText.Remove( i, end - i + 2 );
  34.             }
  35.         } while ( i > 0 && end > 0 );
  36.         
  37.         // Parse the args/dict...
  38.         outArgs.SetArgs( configText );
  39.         
  40.         return true; }
  41.     else {
  42.         return false;
  43.     }    
  44. }